<template>
	<view class="main">
		<view class="header">
			<text>发布新鲜事</text>
			<button class="fabu" @click="fabu">发布</button>
		</view>
		<view class="">
			<view>
				<view class="uni-textarea">
					<textarea v-model="textarea" @blur="getText(value)" placeholder-style="color:#c0c0c0" placeholder="说说新鲜事吧..." />
				</view>
			</view>
			<view class="tupian">
				<input type="file" />
				<robby-image-upload v-model="imageData" @delete="deleteImage" @add="addImage" :enable-drag="enableDrag"
					:enable-del="enableDel" :enable-add="enableAdd" :limit="limitNumber"></robby-image-upload>
			</view>
		</view>
	</view>
</template>

<script>
	import robbyImageUpload from '@/components/robby-image-upload/robby-image-upload.vue';
	export default {
		components: {
			robbyImageUpload
		},
		data() {
			return {
				enableDel: true,
				enableAdd: true,
				enableDrag: true,
				limitNumber: 9,
				imageData: [],
				serverUrl: 'http://172.17.26.211:3313/uploadFile',
				serverUrlDeleteImage: '',
				formData: {},
				images: [],
				textarea:"",
			}
		},
		methods: {
			deleteImage: function(e) {
				console.log(e);
			},
			addImage: function(e) {
				console.log(e);
				console.log(e.currentImages[0]);
				this.images = e.currentImages
			},
			getText(){
				console.log(this.textarea)
			},
			fabu() {
				let timestamp = new Date().getTime();
				console.log(timestamp);
				console.log(this.textarea)
				this.$http({
					url: "/newthing/addNewThing",
					method: "get",
					data: {
						create_time: timestamp,
						imgs_url: this.images[0],
						title: this.textarea,
						wx_user_id: "4"
					}
				})
			},
			// this.$http({
			// 	url: "/uploadFile",
			// 	method: "post",

			// 	// header: "application/form-data"
			// }).then(res => {
			// 	console.log(res);
			// })
		}
	}
</script>

<style lang="less" scoped>
	.main {
		margin: 30rpx;
	}

	.header {
		font-size: 46rpx;
		display: flex;
		justify-content: space-between;
	}

	.fabu {
		height: 60rpx;
		width: 132rpx;
		margin: 0;
		background-color: #f9cc66;
		border: none;
		line-height: 58rpx;
		border-radius: 30rpx;
	}

	.container {
		padding: 10px;
	}

	#editor {
		width: 100%;
		height: 200px;
		background-color: #ffffff;
		margin: 50rpx 0;
	}

	button {
		margin-top: 10px;
	}

	.shangchuan {
		height: 190rpx;
		width: 190rpx;
		background-color: #f2f2f2;
		color: #c7c7c7;
		border-radius: 25rpx;
		text-align: center;
		line-height: 186rpx;
		font-size: 100rpx;
	}
</style>
